﻿namespace UnityEngine
{
    using System;
    using System.Runtime.CompilerServices;

    public class AndroidJNIHelper
    {
        public static ArrayType ConvertFromJNIArray<ArrayType>(IntPtr array)
        {
            return _AndroidJNIHelper.ConvertFromJNIArray<ArrayType>(array);
        }

        public static IntPtr ConvertToJNIArray(Array array)
        {
            return _AndroidJNIHelper.ConvertToJNIArray(array);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern IntPtr CreateJavaRunnable(AndroidJavaRunnable runnable);
        public static jvalue[] CreateJNIArgArray(object[] args)
        {
            return _AndroidJNIHelper.CreateJNIArgArray(args);
        }

        public static IntPtr GetConstructorID(IntPtr javaClass)
        {
            string signature = string.Empty;
            return GetConstructorID(javaClass, signature);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern IntPtr GetConstructorID(IntPtr javaClass, string signature);
        public static IntPtr GetConstructorID(IntPtr jclass, object[] args)
        {
            return _AndroidJNIHelper.GetConstructorID(jclass, args);
        }

        public static IntPtr GetFieldID(IntPtr javaClass, string fieldName)
        {
            bool isStatic = false;
            string signature = string.Empty;
            return GetFieldID(javaClass, fieldName, signature, isStatic);
        }

        public static IntPtr GetFieldID<FieldType>(IntPtr jclass, string fieldName, bool isStatic)
        {
            return _AndroidJNIHelper.GetFieldID<FieldType>(jclass, fieldName, isStatic);
        }

        public static IntPtr GetFieldID(IntPtr javaClass, string fieldName, string signature)
        {
            bool isStatic = false;
            return GetFieldID(javaClass, fieldName, signature, isStatic);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern IntPtr GetFieldID(IntPtr javaClass, string fieldName, string signature, bool isStatic);
        public static IntPtr GetMethodID(IntPtr javaClass, string methodName)
        {
            bool isStatic = false;
            string signature = string.Empty;
            return GetMethodID(javaClass, methodName, signature, isStatic);
        }

        public static IntPtr GetMethodID(IntPtr javaClass, string methodName, string signature)
        {
            bool isStatic = false;
            return GetMethodID(javaClass, methodName, signature, isStatic);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern IntPtr GetMethodID(IntPtr javaClass, string methodName, string signature, bool isStatic);
        public static IntPtr GetMethodID(IntPtr jclass, string methodName, object[] args, bool isStatic)
        {
            return _AndroidJNIHelper.GetMethodID(jclass, methodName, args, isStatic);
        }

        public static IntPtr GetMethodID<ReturnType>(IntPtr jclass, string methodName, object[] args, bool isStatic)
        {
            return _AndroidJNIHelper.GetMethodID<ReturnType>(jclass, methodName, args, isStatic);
        }

        public static string GetSignature(object[] args)
        {
            return _AndroidJNIHelper.GetSignature(args);
        }

        public static string GetSignature(object obj)
        {
            return _AndroidJNIHelper.GetSignature(obj);
        }

        public static string GetSignature<ReturnType>(object[] args)
        {
            return _AndroidJNIHelper.GetSignature<ReturnType>(args);
        }

        public static bool debug { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }
    }
}

